#include <iostream>
#include <string.h>

using namespace std;

const int N = 10;
int w[] = {0, 2, 2, 6, 5, 4};
int v[] = {0, 6, 3, 5, 4, 6};

int a[10][20];
int b[20];

void func()
{
    for (int i = 1; i <= 5; ++i)
    {
        for (int j = 1; j <= N; ++j)
        {
            if (j >= w[i])
            {
                a[i][j] = max(a[i-1][j-w[i]]+v[i], a[i-1][j]);
            }
            else
            {
                a[i][j] = a[i-1][j];
            }
        }
    }

    cout << a[5][N] << endl;
}

void func1()
{
    for (int i = 1; i <= 5; ++i)
    {
        for (int j = N; j >= w[i]; --j)
        {
            b[j] = max(b[j-w[i]]+v[i], b[j]);
        }
    }
    cout << b[N] << endl;
}

int main()
{
    memset(&a, 0, sizeof(a));
    func1();
    return 0;
}
